export type Matrix = number[][]; export type Vector = number[]; /** 完全pivot選択のGauss-Jordan法で複数の連立方程式の解と逆行列を求める * * @param a 連立方程式の係数 * @param bs 求めたい連立方程式の右辺 * @return 連立方程式の解とaの逆行列 export const pivotGaussJordan = (a: Matrix, ...bs: Vector[]): [Matrix, ...Vector[]] => { // 次元チェック const n = a.length; if (!a.every((row) => row.length === n)) throw Error(`a must be a square matrix`); const m = bs.length; if (!b.every((column) => column.length === n)) throw Error(`b must be the same column length as a`); /** pivot選択記録用 */ const indxc: number[] = []; /** pivot選択記録用 */ const indxr: number[] = []; /** pivot選択記録用 */ const ipiv: number[] = new Array(n).fill(0); let big = 0; for (let i = 0; i < n; i++) { big = 0; for (let j = 0; j < n; j++) { if (ipiv[j] === 1) continue; for (let k = 0; k < n; k++) { }